//package com.funny.stock.trade.service;
//
//import com.funny.stock.base.util.CalcUtil;
//import com.funny.stock.trade.dao.pojo.ComposeAssetsActionDO;
//import com.funny.stock.trade.dao.pojo.ComposeAssetsDO;
//import com.funny.stock.trade.dao.repo.ComposeAssetsActionRepo;
//import com.funny.stock.trade.dao.repo.ComposeAssetsRepo;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
///**
// * @author pengl
// * @date 2020/05/23
// **/
//@Component
//public class ComposeAssetsActionHelper {
//    public static final Logger logger = LoggerFactory.getLogger(ComposeAssetsActionHelper.class);
//
//    @Autowired
//    ComposeAssetsActionRepo actionRepo;
//
//    @Autowired
//    ComposeAssetsRepo assetsRepo;
//
//    @Transactional
//    public ComposeAssetsActionDO save(ComposeAssetsActionDO actionDO, ComposeAssetsDO assetsDO){
//        logger.info("save before,assetId:{},balance:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getBalance(), actionDO.getAction(), actionDO.getMoney());
//        logger.info("save before,assetId:{},cash:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getCash(), actionDO.getAction(), actionDO.getMoney());
//
//        assetsDO.setBalance(CalcUtil.calc(actionDO.getAction(),assetsDO.getBalance(),actionDO.getMoney()));
//        assetsDO.setCash(CalcUtil.calc(actionDO.getAction(),assetsDO.getCash(),actionDO.getMoney()));
//
//        logger.info("save after,assetId:{},balance:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getBalance(), actionDO.getAction(), actionDO.getMoney());
//        logger.info("save after,assetId:{},cash:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getCash(), actionDO.getAction(), actionDO.getMoney());
//
//        ComposeAssetsActionDO result = actionRepo.save(actionDO);
//        assetsRepo.save(assetsDO);
//
//        return result;
//    }
//
//    @Transactional
//    public ComposeAssetsActionDO update(ComposeAssetsActionDO actionDO, ComposeAssetsDO assetsDO){
//        actionRepo.findById(actionDO.getId());
//
//        logger.info("update before,assetId:{},balance:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getBalance(), actionDO.getAction(), actionDO.getMoney());
//        logger.info("update before,assetId:{},cash:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getCash(), actionDO.getAction(), actionDO.getMoney());
//
//        assetsDO.setBalance(CalcUtil.calc(actionDO.getAction(),assetsDO.getBalance(),actionDO.getMoney()));
//        assetsDO.setCash(CalcUtil.calc(actionDO.getAction(),assetsDO.getCash(),actionDO.getMoney()));
//
//        logger.info("update after,assetId:{},balance:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getBalance(), actionDO.getAction(), actionDO.getMoney());
//        logger.info("update after,assetId:{},cash:{},action:{},opVal:{}", assetsDO.getId(),assetsDO.getCash(), actionDO.getAction(), actionDO.getMoney());
//
//        ComposeAssetsActionDO result = actionRepo.save(actionDO);
//        assetsRepo.save(assetsDO);
//
//        return result;
//    }
//
//}
